package com.tide.crm.dao;

import java.util.List;
import java.util.Map;

import com.tide.crm.model.ConvergeDictData;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;


@Mapper
public interface ConvergeDictDataDao {

    @Select("select * from converge_dictdata t where t.id = #{id}")
    ConvergeDictData getById(Long id);

    @Delete("delete from converge_dictdata where id = #{id}")
    int delete(Long id);

    int update(ConvergeDictData convergeDictData);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into converge_dictdata(id, create_date, modify_date, data_desc, data_code, data_name, dict_id, order_list) values(#{id}, #{createDate}, #{modifyDate}, #{dataDesc}, #{dataCode}, #{dataName}, #{dictId}, #{orderList})")
    int save(ConvergeDictData convergeDictData);
    
    int count(@Param("params") Map<String, Object> params);

    List<ConvergeDictData> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
    
    
    public List<ConvergeDictData> findDictDataList();
    
    @Select("SELECT t.data_name as dataName, t.data_code as dataCode from converge_dictdata t where t.dict_id = (select d.id as dictId from converge_dict d where d.dict_code = #{dictCode})")
    public List<Map<String,Object>> findDictDataListByDictId(@Param("dictCode") String dictCode);

	public List<ConvergeDictData> findDictDataListByDictIds(@Param("params") Map<String, Object> params);
}
